package com.hzlj.position.locate.controller;


import com.fz.common.base.dto.PageParamDTO;
import com.fz.common.base.dto.QueryPageResultDTO;
import com.fz.common.base.dto.ResultDTO;
import com.fz.common.base.exception.PubException;
import com.hzlj.position.locate.common.common.AbnWarningTrackDTO;
import com.hzlj.position.locate.common.dto.abnProhibitAreasPosition.AbnProhibitAreasPositionQueryParamDTO;
import com.hzlj.position.locate.common.dto.abnProhibitAreasPosition.AbnProhibitAreasPositionQueryResultDTO;
import com.hzlj.position.locate.service.AbnProhibitAreasPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 【禁止区域-定位记录】接口
 *
 * @author lifh
 * @date 2023-03-28 10:20:35
 */
@Slf4j
@RestController
@RequestMapping("/position/abn/prohibit/areas/position")
public class AbnProhibitAreasPositionController {
    @Resource
    private AbnProhibitAreasPositionService abnProhibitAreasPositionService;

    /**
     * 异常数据-跟踪
     */
    @GetMapping("/warning/track/{id}")
    public ResultDTO<AbnWarningTrackDTO> warningTracks(@PathVariable("id") String id) {
        AbnWarningTrackDTO track = abnProhibitAreasPositionService.getWarningTrack(id);
        if(track==null){
            throw new PubException("没有日志信息");
        }
        //原始位置信息
        AbnProhibitAreasPositionQueryResultDTO position = abnProhibitAreasPositionService.getAbnProhibitAreasPositionById(id);
        track.setRecord(position);
        return ResultDTO.ok(track);
    }

    /**
     * 分页查询 禁止区域-定位记录
     */
    @GetMapping("/list/page")
    public ResultDTO<QueryPageResultDTO<AbnProhibitAreasPositionQueryResultDTO>> pageAbnProhibitAreasPosition(AbnProhibitAreasPositionQueryParamDTO dto, PageParamDTO pageParamDTO){
        log.info("【查询分页列表】信息禁止区域-定位记录,AbnProhibitAreasPositionQueryParamDTO={},pageParamDTO={}",dto,pageParamDTO);
        return new ResultDTO<>(abnProhibitAreasPositionService.pageAbnProhibitAreasPosition(dto,pageParamDTO));
    }

}

